/**
 * 
 */
package com.smarthome.core.ads.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.smarthome.base.service.ShAdsService;
import com.smarthome.common.exception.ExceptionUtils;
import com.smarthome.common.tools.SpringUtils;
import com.smarthome.core.ads.AdsService;
import com.smarthome.domain.bean.ShAds;
import com.smarthome.domain.vo.boss.DataGrid;
import com.smarthome.domain.vo.boss.PageHelper;

/**
 * @author dhc
 * @date 2015年11月23日 下午10:00:11
 * @title
 */
@Service("adsService")
public class AdsServiceImpl  implements AdsService{

	@Resource(name="shAdsService")
	private ShAdsService shAdsService;
	
	
	@Override
	public DataGrid queryDataGrid(ShAds ads, PageHelper page) {
		
		
		return shAdsService.selectDatagrid(ads, page);
	}

	@Override
	public ShAds ShAdsById(Long id) {
		return shAdsService.selectEntryById(id);
	}
	@Override
	public void saveAds(ShAds ads) {
		shAdsService.insert(ads);
	}

	@Override
	public void updateAds(ShAds ads) {
	   ShAds queruAds = shAdsService.selectEntryById(ads.getId());
	   
	   if(null == queruAds) throw  new RuntimeException("修改对象为空");
		BeanUtils.copyProperties(ads, queruAds);
		shAdsService.updateById(queruAds);
	}

	@Override
	public List<ShAds> queryAds(ShAds ads) {
		
		return shAdsService.selectEntryList(ads);
	}

}
